package com.stu.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;

@WebServlet("/OutLoginServlet")
public class OutLoginServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        //首先获取登录的用户的会话对象session
        HttpSession session=req.getSession();
        //移除这个会话对象
        session.removeAttribute("session_newUser");
        //跳转到登录界面
        req.getRequestDispatcher("login2.jsp").forward(req, resp);
    }
}
